<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>审核金额设置</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />

<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.validate.min.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<script src="${BasePath}/res/js/common/jquery.validate.method.js" type="text/javascript"></script>
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script>


<style type="text/css">
    body{ font-size:12px;}
    .l-table-edit {}
    .l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
    .l-verify-tip{ left:230px; top:120px;}
    .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
	.p-tab .s-lab{font-size:12px;font-family:"微软雅黑",​"宋体",​Arial,​sans-serif;}
	input.l-textarea{width:170px;height:20px;font-size:12px;}
</style>
</head>
<body style="padding: 10px">
	<div class="navbar">
		<span>您当前的位置：</span> 基础数据管理 &gt; 审核金额设置
	</div>
	<form name="form1" method="post" action="addToAuditSetting.do" id="form1">
		<table cellpadding="0" cellspacing="0" class="l-table-edit p-tab"" >
			<tr>
				<td align="right" class="l-table-edit-td s-lab"><font
					color="red">*</font>用户角色：</td>
				<td align="left" class="l-table-edit-td s-lab">
					<select id="userRole" name="userRole" class="l-textarea" validate="{required:true}" title="请选择角色">
						<option value="" selected="selected">选择角色</option>
						<option value="2">采购总监及运营主管</option>
						<option value="3">财务负责人</option>
						<option value="4">总经理</option>
					</select>
				</td>
				<td align="left"></td>
			</tr>
			<tr>
				<td align="right" class="l-table-edit-td s-lab"><font
					color="red">*</font>金额度  ≥</td>
				<td align="left" class="l-table-edit-td "><input name="money"
					type="text" id="money" value="" class="l-textarea" validate="{required:true,positiveInteger:true,rangelength:[1,9]}"
					maxlength="9"  /></td>
				<td align="left"></td>
			</tr>
			
			<tr>
				<td colspan="3">
				<input type="submit" value="设置" id="submit1" style="font-size: 12px;" class="l-button l-button-submit"/>
				<input type="button" value="取消" name="tests"  style="font-size: 12px;" id="tests" class="l-button l-button-test" />
				</td>
			</tr>
		</table>
	</form>
	<div id="maingrid" style="margin-top: 20px;"></div>
</body>
<script>
	var basePath ="${BasePath}";

	$(function() {
		//validate
		$.metadata.setType("attr", "validate");
		var v = $("form").validate(
				{
				rules: {
			    		"money": {required: true,positive:true}
			    	},
			    	messages: {
			    		"money": {
			    			required: "该字段不能为空",
			    			positive: "只允许输入数字"
			    		}
			    	},
					errorPlacement : function(lable, element) {
						lable.ligerHideTip();
						if (element.hasClass("l-textarea")) {
							element.ligerTip({
								content : lable.html(),
								target : element[0]
							});
						} else if (element.hasClass("l-text-field")) {
							element.parent().ligerTip({
								content : lable.html(),
								target : element[0]
							});
						} else {
							lable.appendTo(element.parents("td:first").next("td"));
						}
					},
					success: function (lable)
			        {
			            lable.ligerHideTip();
			            lable.remove();
			        },
			        submitHandler : function() {
			        	var role = $("#userRole").val();
			    		if(role == ''){
			    			alert("请选择用户角色");
			    			return false;
			    		}
						$("form .l-text,.l-textarea").ligerHideTip();
						var options = {
							type : 'POST',
							success : function(data) {
								if (data == "success") {
									window.parent.f_tip('新增成功');
									window.location.reload();
								} else if(data == "fail"){
									window.parent.f_tip('新增失败');
								}else{
									window.parent.f_tip(data);
								}
							}
						}, $form1 = $("#form1");
						$form1.ajaxSubmit(options);
						return false;
					}
				});
	});
	
	
	$(function () {   	
       grid = $("#maingrid").ligerGrid({
           columns: [
           { display: '用户角色', name: 'userRole',render:function(rowdata,rowindex,value){
              	var text=null;
                switch(value){
                case 2 :
              	  text="采购总监及运营主管";
              	  break;
                case 3:
              	  text="财务负责人";
              	  break;
                case 4:
                  text="总经理";
                  break;
                default :
              	  break;
                }
                return text;
            }},
           { display: '是否审核', name: 'auditState',render:function(rowdata,rowindex,value){
           	var text=null;
               switch(value){
               case 0 :
             	  text="否";
             	  break;
               case 1:
             	  text="是";
             	  break;
               default :
             	  break;
               }
               return text;
           }},
           { display: '金额度', name: 'money'},
           { display: '操作', render: function (rowdata, rowindex, value){
        	    var h = "";
        	    h += "<a href='javascript:eidtAudit(" + rowindex + ")'>修改</a> ";
               return h;
           	}
           }
           ], 
           pageSize:30,
           width: '800',
           dataType: 'server', 
           dataAction: 'server',
           pagesizeParmName: 'pageSize',
           url: "getAjaxPageFinderAuditSetting.do"
       });
   });
	
	
    function eidtAudit(rowindex){
  	  var codeValue=grid.getData()[rowindex].code;
  	  var m=$.ligerDialog.open({title:'审核金额设置',url:basePath+'/base/auditSetting/toUpdateAuditSetting.do?code='+codeValue,height:350,width:600,isResize: false, isDrag: false });
  	  m.show(); 
    }
    	
 // 取消
    $("#tests").click(function() {
   	close_liger_tab();
   });	
	
</script>
</html>